package com.xquant.marketdata.marketdata.controller;

import com.github.pagehelper.PageInfo;
import com.xquant.marketdata.marketdata.service.IndexService;
import com.xquant.marketdata.utils.CommResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

import static com.xquant.common.core.utils.PageUtils.startPage;

/**
 * 指数
 * newCloud
 *
 * @author ershuai.zhao
 */
@RestController
@RequestMapping("indexController")
public class IndexController {

    @Autowired
    private IndexService indexService;

    /**
     * 查询 指数信息
     */
    @RequestMapping(value = "/queryIndexInfoByPage.action")
    @PreAuthorize("@ss.hasPermi('marketdata:equity:index:indexDataInfo:list')")
    public PageInfo<Map> queryIndexInfoByPage(@RequestParam Map<String, Object> param) {
        startPage();
        PageInfo<Map> pageInfo = indexService.queryIndexInfoByPage(param);
        return pageInfo;
    }

    /**
     * 查询 指数信息下拉框
     */
    @RequestMapping(value = "/getIndexInfo.action")
    public Object getIndexInfo(@RequestParam Map<String, Object> param) {
        PageInfo<Map> pageInfo = indexService.getIndexInfo(param);
        return pageInfo.getList();
    }

    /**
     * 查询 指数分红
     */
    @RequestMapping(value = "/queryIndexPriceByPage.action")
    @PreAuthorize("@ss.hasPermi('marketdata:equity:tidx:tidxSeries:list')")
    public PageInfo<Map> queryIndexPriceByPage(@RequestParam Map<String, Object> param) {
        startPage();
        PageInfo<Map> pageInfo = indexService.queryIndexPriceByPage(param);
        return pageInfo;
    }

    /**
     * 查询 指数成份
     */
    @RequestMapping(value = "/queryIndexCompByPage.action")
    @PreAuthorize("@ss.hasPermi('marketdata:equity:index:indexDataComp:list')")
    public PageInfo<Map> queryIndexCompByPage(@RequestParam Map<String, Object> param) {
        startPage();
        PageInfo<Map> pageInfo = indexService.queryIndexCompByPage(param);
        return pageInfo;
    }

    /**
     * 新增 指数成份
     */
    @RequestMapping(value = "/insertIndexComp.action")
    public CommResponse insertIndexComp(@RequestParam Map<String, Object> param) {
        indexService.insertIndexComp(param);
        return CommResponse.success("新增指数成分成功！");
    }


    /**
     * 新增 新增指数行情
     */
    @RequestMapping(value = "/insertIndexPrice.action")
    public CommResponse insertIndexPrice(@RequestParam Map<String, Object> param) {

        indexService.insertIndexPrice(param);

        return CommResponse.success("新增指数行情成功！");
    }


    /**
     * 新增 指数信息
     */
    @RequestMapping(value = "/insertIndexInfo.action")
    public CommResponse insertIndexInfo(@RequestParam Map<String, Object> param) {

        indexService.insertIndexInfo(param);

        return CommResponse.success("新增指数信息成功！");
    }


    /**
     * 修改 指数成份
     */
    @RequestMapping(value = "/updateIndexComp.action")
    public CommResponse updateIndexComp(@RequestParam Map<String, Object> param) {

        indexService.updateIndexComp(param);

        return CommResponse.success("修改指数成分成功！");
    }


    /**
     * 修改指数行情
     */
    @RequestMapping(value = "/updateIndexPrice.action")
    public CommResponse updateIndexPrice(@RequestParam Map<String, Object> param) {
        indexService.updateIndexPrice(param);
        return CommResponse.success("修改指数行情成功！");
    }


    /**
     * 新增 指数信息
     */
    @RequestMapping(value = "/updateIndexInfo.action")
    public CommResponse updateIndexInfo(@RequestParam Map<String, Object> param) {

        indexService.updateIndexInfo(param);

        return CommResponse.success("修改指数信息成功！");
    }


    /**
     * 删除 指数成份
     */
    @RequestMapping(value = "/deleteIndexComp.action")
    public CommResponse deleteIndexComp(@RequestParam Map<String, Object> param) {

        indexService.deleteIndexComp(param);

        return CommResponse.success("修改指数成分成功！");
    }


    /**
     * 删除指数行情
     */
    @RequestMapping(value = "/deleteIndexPrice.action")
    public CommResponse deleteIndexPrice(@RequestParam Map<String, Object> param) {

        indexService.deleteIndexPrice(param);

        return CommResponse.success("删除指数行情成功！");
    }


    /**
     * 删除 指数信息
     */
    @RequestMapping(value = "/deleteIndexInfo.action")
    public CommResponse deleteIndexInfo(@RequestParam Map<String, Object> param) {

        indexService.deleteIndexInfo(param);

        return CommResponse.success("删除指数信息成功！");
    }


}
